﻿<%@ Page Title="Users management" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="UtilisateurManagement.aspx.cs" Inherits="IAATO.UtilisateurManagement" MaintainScrollPositionOnPostback="true" %>


<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">

    <asp:HiddenField runat="server" ID="hdfScrollIntoView" Value="False" />
    <script>
        if (document.getElementById('<% =hdfScrollIntoView.ClientID %>').value == 'True') {
            window.onload = function () { document.getElementById('<% =Table1.ClientID %>').scrollIntoView(); };
            document.getElementById('<% =hdfScrollIntoView.ClientID %>').value = 'False';
        }
    </script>

    <h1><%: Title %></h1>
    <br />

    <asp:Label runat="server" ID="lblError" Text="" Font-Bold="true" ForeColor="Red"></asp:Label>
        <asp:GridView ID="gdwUtilisateurs" OnPageIndexChanging="gdwUtilisateurs_PageIndexChanging" CssClass="gridView" runat="server" AutoGenerateColumns="False" CellSpacing="-1" AllowPaging="True">
        <Columns>
            <asp:TemplateField HeaderText="Username">
                <ItemTemplate>
                    <asp:Label ID="lblNom" Text='<%# Eval("UserName") %>' runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
        

            <asp:TemplateField HeaderText="Email">
                <ItemTemplate>
                    <asp:Label ID="lblEmail" Text='<%# Eval("Email") %>' runat="server" />
                </ItemTemplate>
            </asp:TemplateField>


           <asp:TemplateField HeaderText="Role">
                <ItemTemplate>
                    <asp:Label ID="lblRole" Text='<%# Roles.GetRolesForUser(Eval("UserName").ToString()).First() %>' runat="server" />
                </ItemTemplate>
            </asp:TemplateField>


            <asp:TemplateField HeaderText="Edit">
                <ItemTemplate>
                    <asp:ImageButton ImageUrl="~/Images/edit/edit-26.png" ID="modifierButton" CommandArgument='<%# Eval("UserName") %>' OnClick="update_Click"  runat="server" Width="26" Height="26" BackColor="Transparent" />
                </ItemTemplate>
            </asp:TemplateField>


            <asp:TemplateField HeaderText="Delete">
                <ItemTemplate>
                    <asp:ImageButton ImageUrl="~/Images/delete/delete-26.png" ID="deleteButton" CommandArgument='<%# Eval("UserName") %>' OnClientClick="return confirm('Do you really want to delete this lign?');" OnClick="delete_Click" runat="server" Width="26" Height="26" BackColor="Transparent" />
                </ItemTemplate>
            </asp:TemplateField>


        </Columns>
        </asp:GridView>


    <br />


    <asp:Table runat="server" ID="Table1" CssClass="tableModifier">
        <asp:TableHeaderRow>
            <asp:TableHeaderCell>Username</asp:TableHeaderCell>      
            <asp:TableHeaderCell>Email</asp:TableHeaderCell>
            <asp:TableHeaderCell>Role</asp:TableHeaderCell>

        </asp:TableHeaderRow>
        <asp:TableRow>
            <asp:TableCell><asp:TextBox runat="server" ID="txtNom" Width="110" Height="12" Font-Size="Small"></asp:TextBox></asp:TableCell>
            <asp:TableCell><asp:TextBox runat="server" ID="txtEmail" Width="110" Height="12" Font-Size="Small"></asp:TextBox></asp:TableCell>
            <asp:TableCell><asp:DropDownList runat="server" ID="ddlRole"></asp:DropDownList></asp:TableCell>
            <asp:TableCell>
                <asp:Button runat="server" ID="btnAjouter" Text="Add" OnClick="btnAjouter_Click"></asp:Button>
                <asp:Button runat="server" ID="btnModifier" Text="Save" OnClick="btnModifier_Click" Visible="false"></asp:Button>
                <asp:Button runat="server" ID="btnAnnuler" Text="Cancel" OnClick="btnAnnuler_Click" Visible="false"></asp:Button>
                <asp:HiddenField runat="server" ID="userNameUpdate" Visible="false"/>
            </asp:TableCell>
        </asp:TableRow>
    </asp:Table>

    <asp:Label runat="server" ID="lblErrorUserName" Text="" Font-Bold="true" ForeColor="Red"></asp:Label>


</asp:Content>